package com.dongdongshop.service.impl;

import com.dongdongshop.domain.model.TUser;
import com.dongdongshop.domain.model.TUserExample;
import com.dongdongshop.mapper.TUserMapper;
import com.dongdongshop.service.UserLoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserLoginServiceImpl implements UserLoginService {

    @Autowired
    private TUserMapper tm;

    @Override
    public TUser selectByUsername(String pname) {
        TUserExample te = new TUserExample();
        te.createCriteria().andNameEqualTo(pname);
        List<TUser> userList = tm.selectByExample(te);
        return userList == null || userList.isEmpty() ? null : userList.get(0);
    }
}
